package com.aixin.csopservice.service.impl;

import com.aixin.csopservice.domain.MessageDomain;
import com.aixin.csopservice.model.MessageModel;
import com.aixin.csopservice.repository.MessageRepository;
import com.aixin.csopservice.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

@Service
public class MessageServiceImpl  implements MessageService {

    @Autowired
    MessageRepository messageRepository;

    @Override
    public Page<MessageDomain> getMessage(MessageModel messageModel, int pageNum, int pageSize) {
        Pageable pageRequest = new PageRequest(pageNum-1, pageSize, Sort.Direction.DESC, "createTime");
        return messageRepository.getMessage(messageModel.getCustName(),messageModel.getCustPhoneNum(),messageModel.getTemplatesID(),messageModel.getMessageStatus(),messageModel.getStartTime(),messageModel.getEndTime(),pageRequest);
    }
}
